package com.red.star.wechat.data.utils;

import com.red.star.wechat.data.core.constant.SmsConstant;
import com.red.star.wechat.data.entity.SysParam;
import org.apache.http.client.fluent.Request;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class SmsUtil {

    public static void sendMsg(String mobiles,String smsType) throws IOException {
        Map<String,String> param = new HashMap<String,String>();
        param.put("appId","5429255E");
        param.put("appSecret","51f44cf8b5d0096d38b3aa3e39922425552a0ea1");
        param.put("mobiles",mobiles);
        param.put("smsType",smsType);
        Request request = Request.Post("http://wechat.dev.rs.com/wechat/sendMsg.json");
        String res = HttpUtil.fetch(request,param);
        System.out.println(res);
    }


    public static String sendSms(String mobiles, String content) {
        String path = SysParam.MACALLINE_SMS_URL;
        path = path + "?mobiles=" + mobiles + "&content=" + content + "&channelName=" + SmsConstant.CHANNEL_NAME +
                "&businessName=" + SmsConstant.BUSINESS_NAME;
        System.out.println(path);
        Request request = Request.Get(path);
        request.setHeader("Content-Type", "application/json");
        return HttpUtil.fetch(request);
    }

    public static void main(String args[]) throws IOException {
        String mes = sendSms("18395586376", "你是猪");
        System.out.println(mes);
    }
}
